let gulp = require('gulp');
//当发生异常时提示错误 确保本地安装gulp-notify和gulp-plumber
let rename = require('gulp-rename');
let uglify = require('gulp-uglify');

gulp.task('js', function () {
    gulp.src('src/*.js')
        .pipe(uglify({
            mangle: {
                toplevel: true,
            }
        }))
        .on('error', function (e) {//压缩
            console.log(e);
        })
        .pipe(rename({extname: '.js'}))
        .pipe(gulp.dest('dist'))
});

gulp.task('watch', function () {
    gulp.watch('src/*.js', gulp.series('js'));
});

gulp.task('build', gulp.series('js'));
